package com.example.freeengine.wallpaper.network;

import android.content.Context;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

/**
 * @author Terry Deng
 */
public class MyVolleyRequestQueueSingleton {

    static MyVolleyRequestQueueSingleton myVolleyRequestQueueSingleton;
    private RequestQueue requestQueue;
    private Context context;

    private MyVolleyRequestQueueSingleton(){}
    private MyVolleyRequestQueueSingleton(Context context){
        this.context = context;
    }
    public static synchronized MyVolleyRequestQueueSingleton getInstance(Context context){
        if (myVolleyRequestQueueSingleton == null){
            myVolleyRequestQueueSingleton = new MyVolleyRequestQueueSingleton(context);
        }
        return myVolleyRequestQueueSingleton;
    }

    public synchronized RequestQueue getRequestQueue(){
        if (requestQueue == null){
            requestQueue = Volley.newRequestQueue(context.getApplicationContext());
        }
        return requestQueue;
    }

}
